package com.atstudy.buffer;

import java.io.*;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2022/12/29 13:42
 * @copyright: 博为峰
 */
public class BufferedInOutStreamDemo {
    public static void main(String[] args) throws IOException {
//        m1();
        FileInputStream fileInputStream = new FileInputStream("C:\\Users\\admin\\Desktop\\java29\\io\\bos.txt");
        BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
        byte[] bytes = new byte[1024];
        int count = 0;
        while ((count = bufferedInputStream.read(bytes)) != -1) {
            String str = new String(bytes, 0, count);
            System.out.println(str);
        }
    }

    private static void m1() throws IOException {
        FileOutputStream fileOutputStream = new FileOutputStream("C:\\Users\\admin\\Desktop\\java29\\io\\bos.txt");
        BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
        bufferedOutputStream.write("博为峰".getBytes());
        bufferedOutputStream.close();
    }
}
